package blackbirdisoserver;

import java.io.IOException;

import org.jpos.iso.*;
import org.jpos.util.*;
import org.jpos.iso.channel.*;
import org.jpos.iso.packager.*;

public class TestServer implements ISORequestListener
{
	public static void main(String[] args) throws Exception
	{
		Logger logger = new Logger();
		logger.addListener(new SimpleLogListener(System.out));
		ServerChannel channel = new XMLChannel(new XMLPackager());
		((LogSource)channel).setLogger(logger, "channel");

		ISOServer server = new ISOServer(8000, channel, null);
		server.setLogger(logger, "server");
		server.addISORequestListener(new TestServer());
		new Thread(server).start();
		
	}

	@Override
	public boolean process(ISOSource source, ISOMsg m)
	{
		try
		{
			m.setResponseMTI();
			m.set(3, "12");
			m.set(39, "00");
			source.send(m);
		}
		catch (ISOException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		return true;
	}

}
